<?php

class productTable {

    /**
     * Get a specific product in table by it's Id
     * @param type $id
     * @return type 
     */
    public static function o_getProductById($id) {
        $o_connection = dbconnection::getInstance();
        $sz_sql = "select * from product where id='" . $id . "'";

        $a_res = $o_connection->doQueryObject($sz_sql, "product");

        if ($a_res === false)
            return false;

        return $a_res[0];
    }

    /**
     * Get All Product in database
     */
    public static function a_getAllProduct() {
        $o_connection = dbconnection::getInstance();
        $sz_sql = "select * from product ";

        $a_res = $o_connection->doQueryObject($sz_sql, "product");

        if ($a_res === false)
            return false;

        return $a_res;
    }
	 /**
	 * Get All product having axis
	 */
	public static function a_getAxedProduct() {
		$o_connection = dbconnection::getInstance();
		$sz_sql = "SELECT id_product FROM product_axis ";
		$sz_sql .= "JOIN product ON product.id = product_axis.id_product ";
		$sz_sql .= "GROUP BY id_product ";

		$a_res = $o_connection->doQueryObject($sz_sql, "product");

		if ($a_res === false)
			return false;

		return $a_res;
	}
}
